import request from '@/utils/http'

// 用户数据接口
export interface UserData {
  id: number
  created_at: string | null
  updated_at: string | null
  username: string
  password: string | null
  phone: string
  email: string | null
  status: boolean
  head_img_url: string
  nick_name: string
  gender: number | null
  max_storage: number
  used_storage: number
  user_login_name: string | null
  third_party_platforms: any[]
}

// 用户查询参数
export interface UserQueryParams {
  page: number
  pageSize: number
  sort?: string
  role?: string
  keyword?: string
}

// 创建用户参数
export interface CreateUserParams {
  username: string
  password: string
  phone: string
  email?: string
  status: boolean
  nickName: string
  gender?: number
}

// 获取用户列表
export const getUserList = (params: UserQueryParams) => {
  return request.post<{
    code: number
    msg: string
    data: {
      list: UserData[]
      total: number
      page: number
      pageSize: number
    }
  }>({
    url: '/api/userBack/list',
    data: params
  })
}

// 删除用户
export const deleteUser = (id: number) => {
  return request.del<{
    code: number
    msg: string
    data: null
  }>({
    url: `/api/userBack/${id}`
  })
}

// 创建用户
export const createUser = (params: CreateUserParams) => {
  return request.post<{
    code: number
    msg: string
    data: UserData
  }>({
    url: '/api/userBack/create',
    data: params
  })
} 